﻿using Logistics.Statist;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace Logistics.Web.Controllers
{
    public class StatistController : Controller
    {
        private readonly IStatitsAppService _StatitsAppService;

        public StatistController(IStatitsAppService statitsAppService)
        {
            _StatitsAppService = statitsAppService;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Task DeleteAsyncc(int id)
        {
            var i = _StatitsAppService.DeleteAsync(id);
            return i;
        }
        /// <summary>
        /// 查看视图
        /// </summary>
        /// <returns></returns>
        public ActionResult GetProcIndex(int id)
        {
            ViewBag.Id = id;
            return View();
        }
        /// <summary>
        /// 反填视图
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult PutProcIndex(int id)
        {
            ViewBag.Id = id;
            return View();
        }
        public IActionResult Updates(StatistDto Statist)
        {
            var procur = _StatitsAppService.UpdateAsync(Statist);
            return Ok(procur);
        }

        /// <summary>
        /// 查看详情/反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Task<StatistDto> GetAsyncc(int id)
        {
            var Procur = _StatitsAppService.GetAsync(id);
            return Procur;
        }
        /// <summary>
        /// 添加视图
        /// </summary>
        /// <returns></returns>
        public ActionResult PostProcIndex()
        {
            return View();
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="Procurement"></param>
        /// <returns></returns>
        public IActionResult Add(StatistDto Statist)
        {
            var i = _StatitsAppService.CreateAsync(Statist).Result;
            return Ok(i);
        }

        // GET: ApproveController
        public ActionResult ApproveIndex()
        {
            //GetListAsync(pageIndex);
            return View();
        }

        // GET: ApproveController/Details/5
        public JsonResult ShowProcurementAsynccc(GetStatitsListDto getStatitsListDto)
        {
            var Procurements = _StatitsAppService.GetListAsync(getStatitsListDto).Result;
            return Json(new { data = Procurements.Items, count = Procurements.TotalCount, code = "0", msg = "" });
        }
    }
}
